<script setup>
import HomePanel from './HomePanel.vue'
import { onMounted, ref } from 'vue'
import goodsImg1 from '@/assets/uploads/人气推荐1.png'
import goodsImg2 from '@/assets/uploads/人气推荐2.png'
import goodsImg3 from '@/assets/uploads/人气推荐3.png'
import goodsImg4 from '@/assets/uploads/人气推荐4.png'

// 使用静态数据和本地图片
const hotList = ref([
  {
    id: 1,
    title: '人气爆款 有机蔬菜套装',
    alt: '当日采摘 新鲜直达',
    picture: goodsImg1
  },
  {
    id: 2,
    title: '热销推荐 进口水果礼盒',
    alt: '多国精选 品质保证',
    picture: goodsImg2
  },
  {
    id: 3,
    title: '限时特惠 散养土鸡蛋',
    alt: '无抗生素 营养丰富',
    picture: goodsImg3
  },
  {
    id: 4,
    title: '热卖商品 精选海鲜组合',
    alt: '新鲜捕捞 冷链配送',
    picture: goodsImg4
  }
])

// 保留初始化函数以维持兼容性
const getHotList = async () => {
  // 已经有静态数据，不需要再请求
  console.log('使用静态人气推荐数据')
}

// 组件挂载时仍调用函数，保持原有的行为模式
onMounted(() => getHotList())


</script>

<template>
  <HomePanel title="人气推荐" sub-title="人气爆款 不容错过">
    <ul class="goods-list">
      <li v-for="item in hotList" :key="item.id">
        <RouterLink to="/">
          <img v-img-lazy="item.picture" :alt="item.alt">
          <p class="name">{{ item.title }}</p>
          <p class="desc">{{ item.alt }}</p>
        </RouterLink>
      </li>
    </ul>
  </HomePanel>
</template>

<style scoped lang='scss'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 426px;

  li {
    width: 306px;
    height: 406px;
    transition: all .5s;

    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }

    img {
      width: 306px;
      height: 306px;
    }

    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
    }

    .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>